package mgt.pages

import gateway.mgt.api.ApiConstantParam

class ApiConstantParamCreatePage extends geb.Page {
    static url = "/apiConstantParam/create"

    static content = {
        apiDefinitionSelect(wait: true) { $("#apiDefinition") }

        orderField(wait: true) { $("#order") }
        typeField(wait: true) { $("#type") }
        scopeField(wait: true) { $("#scope") }
        nameField(wait: true) { $("#name") }
        valueField(wait: true) { $("#value") }
        descriptionField(wait: true) { $("#description") }

        createButton(to: ApiConstantParamShowPage) { $(".save") }
    }

    ApiConstantParamShowPage createApiConstantParam(Long apiDefinitionId, Integer order, ApiConstantParam.Type type, ApiConstantParam.Scope scope, String name, String value, String description) {
        apiDefinitionSelect.value(apiDefinitionId)

        orderField.value(order)
        typeField.value(type)
        scopeField.value(scope)
        nameField.value(name)
        valueField.value(value)
        descriptionField.value(description)

        createButton.click()

        return browser.page
    }
}